<?php
/**
 * Displays pages for static content
 *
 * ACCESS: PUBLIC
 *
 * @author Brian C
 * @version 1.0
 */
class Photos extends Controller {
	
	/**
	 * Class constructor
	 */
	function __construct() {
		parent::__construct();
		
		$this->badger->checkRemember();
	}
	
	/**
	 * Loads the photos page
	 */
	function index() {
		$data = $this->_buildContent();
		$data['pagetype'] = 'nobg';
		$this->load->view('photos/main',$data);
	}
	
	/**
	 * Loads the Upload Photo page
	 */
	function upload() {
		$data = $this->_buildContent();
		$data['pagetype'] = 'nobg';
		$this->load->view('photos/upload',$data);
	}
	
	/*
	 * Supplies user-specific information to the interface for customization
	 * REQUIRED DATA ARRAY PARAMS:
	 * pagetype = page, page-admin, nobg
	 * loggedin = isset
	 */
	function _buildContent() {
		$data = array();
		if ($this->session->flashdata('msg_info')) $data['msg_info'] = $this->session->flashdata('msg_info');
		if ($this->session->flashdata('msg_error'))	$data['msg_error'] = $this->session->flashdata('msg_error');
		
		if ($this->session->userdata('loggedin')) {
			$this->load->model('UserModel');
			$user = $this->UserModel->getUserByName($this->session->userdata('username'));
			
			$data['con_user'] = $user;
			$data['loggedin'] = TRUE;
			
			//is admin?
			if ($this->UserModel->isUserInGroup($user->userid,$this->UserModel->getGroupID('admin'))) {
				$data['admin_tab'] = TRUE;
			}
			
			//can upload photos?
			if($this->UserModel->isUserInGroup($user->userid,$this->UserModel->getGroupID('photos'))) {
				$data['photos_upload'] = TRUE;
			}
			
			//is prayer team?
			if ($this->UserModel->isUserInGroup($user->userid,$this->UserModel->getGroupID('lg_pop'))) {
				$data['prayer_tab'] = TRUE;
			}
		}
		
		return $data;
	}
}


// END Photos class

/* End of file photos.php */
/* Location: ./system/application/controllers.php */
